<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of gauseval</title>
  <meta name="keywords" content="gauseval">
  <meta name="description" content="GAUSEVAL  Calculates the likelihood of a dataset X under a Gaussian probability">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../menu.html">Home</a> &gt;  <a href="#">ReBEL-0.2.7</a> &gt; <a href="#">core</a> &gt; gauseval.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../menu.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="menu.html">Index for .\ReBEL-0.2.7\core&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>gauseval
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>GAUSEVAL  Calculates the likelihood of a dataset X under a Gaussian probability</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function likelihood = gauseval(gausDS, X, logflag) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> GAUSEVAL  Calculates the likelihood of a dataset X under a Gaussian probability
           density described by the Gaussian data structure 'gausDS',
           i.e. P(X|gausDS). The column vectors of X are treated as IID samples to be
           evaluated. The function return a likelihood row-vector that contains one
           likelihood value for each IID sample in X.

   likelihood = gauseval(gausDS, X)

   INPUT
          gausDS       Gaussian data structure with the following fields
             .cov_type (string) covariance matrix type 'full' , 'diag' , 'sqrt' , 'sqrt-diag'
             .dim      (scalar)   dimension
             .mu       (c-vector) mean vector  (dim-by-1)
             .cov      (matrix)   covariance matrix of type cov_type  (dim-by-dim)
          X            (dim-by-M) buffer of M dim-by-1 data set vectors to be evaluated
          logflag      &lt;optional&gt; if 'logflag==1' then the probability is calculated in the log
                                  domain, i.e. likelihood=log(likelihood) (default : logflag=0)
   OUTPUT
          likelihood   (1-by-M) buffer of likelihood values

   See also
     GAUSSAMP
   Copyright (c) Oregon Health &amp; Science University (2006)

   This file is part of the ReBEL Toolkit. The ReBEL Toolkit is available free for
   academic use only (see included license file) and can be obtained from
   http://choosh.csee.ogi.edu/rebel/.  Businesses wishing to obtain a copy of the
   software should contact rebel@csee.ogi.edu for commercial licensing information.

   See LICENSE (which should be part of the main toolkit distribution) for more
   detail.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="cvecrep.html" class="code" title="function m = cvecrep(v,c)">cvecrep</a>	CVECREP  Column vector replicate</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="gennoiseds.html" class="code" title="function NoiseDS = gennoiseds(ArgDS)">gennoiseds</a>	GENNOISEDS    Generates a NoiseDS data structure describing a noise source.</li></ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function likelihood = gauseval(gausDS, X, logflag)</a>
0002 
0003 <span class="comment">% GAUSEVAL  Calculates the likelihood of a dataset X under a Gaussian probability</span>
0004 <span class="comment">%           density described by the Gaussian data structure 'gausDS',</span>
0005 <span class="comment">%           i.e. P(X|gausDS). The column vectors of X are treated as IID samples to be</span>
0006 <span class="comment">%           evaluated. The function return a likelihood row-vector that contains one</span>
0007 <span class="comment">%           likelihood value for each IID sample in X.</span>
0008 <span class="comment">%</span>
0009 <span class="comment">%   likelihood = gauseval(gausDS, X)</span>
0010 <span class="comment">%</span>
0011 <span class="comment">%   INPUT</span>
0012 <span class="comment">%          gausDS       Gaussian data structure with the following fields</span>
0013 <span class="comment">%             .cov_type (string) covariance matrix type 'full' , 'diag' , 'sqrt' , 'sqrt-diag'</span>
0014 <span class="comment">%             .dim      (scalar)   dimension</span>
0015 <span class="comment">%             .mu       (c-vector) mean vector  (dim-by-1)</span>
0016 <span class="comment">%             .cov      (matrix)   covariance matrix of type cov_type  (dim-by-dim)</span>
0017 <span class="comment">%          X            (dim-by-M) buffer of M dim-by-1 data set vectors to be evaluated</span>
0018 <span class="comment">%          logflag      &lt;optional&gt; if 'logflag==1' then the probability is calculated in the log</span>
0019 <span class="comment">%                                  domain, i.e. likelihood=log(likelihood) (default : logflag=0)</span>
0020 <span class="comment">%   OUTPUT</span>
0021 <span class="comment">%          likelihood   (1-by-M) buffer of likelihood values</span>
0022 <span class="comment">%</span>
0023 <span class="comment">%   See also</span>
0024 <span class="comment">%     GAUSSAMP</span>
0025 <span class="comment">%   Copyright (c) Oregon Health &amp; Science University (2006)</span>
0026 <span class="comment">%</span>
0027 <span class="comment">%   This file is part of the ReBEL Toolkit. The ReBEL Toolkit is available free for</span>
0028 <span class="comment">%   academic use only (see included license file) and can be obtained from</span>
0029 <span class="comment">%   http://choosh.csee.ogi.edu/rebel/.  Businesses wishing to obtain a copy of the</span>
0030 <span class="comment">%   software should contact rebel@csee.ogi.edu for commercial licensing information.</span>
0031 <span class="comment">%</span>
0032 <span class="comment">%   See LICENSE (which should be part of the main toolkit distribution) for more</span>
0033 <span class="comment">%   detail.</span>
0034 
0035 <span class="comment">%=============================================================================================</span>
0036 
0037 <span class="keyword">switch</span> nargin
0038 <span class="keyword">case</span> 3
0039 <span class="keyword">case</span> 2
0040   logflag=0;
0041 <span class="keyword">otherwise</span>
0042   error(<span class="string">' [ gauseval ] Not enough inputs.'</span>);
0043 <span class="keyword">end</span>
0044 
0045 
0046 nov = size(X, 2);                <span class="comment">% number of input vectors</span>
0047 likelihood = zeros(1, nov);      <span class="comment">% preallocate likelihood matrix</span>
0048 
0049 
0050 <span class="keyword">switch</span> gausDS.cov_type           <span class="comment">% calculations depend on covariance type</span>
0051 
0052 <span class="keyword">case</span> {<span class="string">'full'</span>,<span class="string">'diag'</span>}
0053 
0054     normfact = (2*pi)^(gausDS.dim/2);
0055     XX = X - <a href="cvecrep.html" class="code" title="function m = cvecrep(v,c)">cvecrep</a>(gausDS.mu, nov);
0056     S = chol(gausDS.cov)';
0057     foo = S \ XX;
0058     <span class="keyword">if</span> logflag
0059         likelihood = -0.5*sum(foo.*foo, 1) - log(normfact*abs(prod(diag(S))));
0060     <span class="keyword">else</span>
0061         likelihood = exp(-0.5*sum(foo.*foo, 1))./(normfact*abs(prod(diag(S))));
0062     <span class="keyword">end</span>
0063 
0064 <span class="keyword">case</span> {<span class="string">'sqrt'</span>,<span class="string">'sqrt-diag'</span>}
0065 
0066     normfact = (2*pi)^(gausDS.dim/2);
0067     XX = X - <a href="cvecrep.html" class="code" title="function m = cvecrep(v,c)">cvecrep</a>(gausDS.mu, nov);
0068     S = gausDS.cov;
0069     foo = S \ XX;
0070     <span class="keyword">if</span> logflag
0071         likelihood = -0.5*sum(foo.*foo, 1) - log(normfact*abs(prod(diag(S))));
0072     <span class="keyword">else</span>
0073         likelihood = exp(-0.5*sum(foo.*foo, 1))./(normfact*abs(prod(diag(S))));
0074     <span class="keyword">end</span>
0075 
0076 
0077 <span class="keyword">otherwise</span>
0078 
0079     error([<span class="string">' [ gauseval ] Unknown covariance type '</span>, mix.cov_type]);
0080 
0081 <span class="keyword">end</span>
0082</pre></div>
<hr><address>Generated on Tue 26-Sep-2006 10:36:21 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>